<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组方法 </title>
</head>
<body>
<h2>位移元素</h2>
<p>shift() 方法会删除首个数组元素，并把所有其他元素“位移”到更低的索引(移到左侧）。</p>


<p id="demo1"></p>
<p id="demo2"></p>

<script>
  var fruits = ["Banana", "Orange", "Apple", "Mango"];
  document.getElementById("demo1").innerHTML=fruits;
  fruits.shift();
  document.getElementById("demo2").innerHTML=fruits;
</script>
</body>
</html>


<!--
运行结果：
Banana,Orange,Apple,Mango

Orange,Apple,Mango

document.getElementById("demo2").innerHTML = fruits.shift();
返回被“位移出”的字符串：Banana
-->